package init

import (
	"flag"
	"gateway/basic/config"
	"log"

	__ "gateway/basic/proto"
	"google.golang.org/grpc"
	"google.golang.org/grpc/credentials/insecure"
)

func InitsGrpc() {
	////实例化consul
	//address := "14.103.175.162:8500"
	//consulClient, err := untils.NewConsul(address)
	//if err != nil {
	//	panic(err)
	//}
	//
	////初始化rpc配置
	//cfg := untils.GRPCService{
	//	Name:    "service",
	//	Tage:    []string{"service"},
	//	Address: "127.0.0.1",
	//	Port:    50051,
	//}
	//
	////将服务注册到consul
	//err = consulClient.RegisterService(&cfg)
	//if err != nil {
	//	panic(err)
	//}

	flag.Parse()
	addr := "127.0.0.1:50051"
	conn, err := grpc.NewClient(addr, grpc.WithTransportCredentials(insecure.NewCredentials()))
	if err != nil {
		log.Fatalf("did not connect: %v", err)
	}
	config.ClearClient = __.NewClearClient(conn)

}
